package com.itheima.demo.demo03.demo04;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Hashmap {
    public static void main(String[] args) {
        Map<Integer,String> map=new HashMap<>();
        map.put(1,"犬夜叉");
        map.put(1,"杀生丸");
        map.put(2,"般若");
        map.put(3,"酒吞");
        //key不变value变化，前者的value将会别后者取代
        System.out.println(map);
        String r = map.remove(2);
        System.out.println(r);
        System.out.println(map);
        String s = map.get(3);
        System.out.println(s);
        boolean b = map.containsKey(2);
        System.out.println(b);//false因为我在之前把key 2去掉了
        int size = map.size();
        System.out.println(size);
        Set<Integer> keys = map.keySet();
        for (Integer key : keys) {
            String s1 = map.get(key);
            System.out.println(s1);
        }
        Set<Map.Entry<Integer, String>> entries = map.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            Integer key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key+" "+value);
        }



    }
}
